/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PlanOut.java
 *
 * Created on Feb 28, 2012, 5:59:07 PM
 */

package UserInterface;

import AI.UserPlanOut;
import java.text.DecimalFormat;

/**
 *
 * @author Harsha
 */
public class PlanOut extends javax.swing.JFrame {
private UserPlanOut out;
    /** Creates new form PlanOut */
    public PlanOut(UserPlanOut plan) {
        initComponents();
        this.out=plan;
        setLocationRelativeTo(this);
        setData();
        setVisible(true);
        
    }
    private double roundTwoDecimals(double d) {
            DecimalFormat twoDForm = new DecimalFormat("#.##");
        return Double.valueOf(twoDForm.format(d));
}
    public void setData()
    {
       
        String route1="";
        for(int i=0;i<out.getRoute().size();i++)
        {
            route1+=out.getRoute().get(i).getName()+" ";
            System.out.println("Adding");
        }
        route.setText (route1);
        for(int j=0;j<out.getDayPlan().size();j++)
        {
           visitingPlaces.append("Day"+(j+1)+"\n");
           breakFirst.append("Day"+(j+1)+"\n");
           Lunch.append("Day"+(j+1)+"\n");
           evening.append("Day"+(j+1)+"\n");
           dinner.append("Day"+(j+1)+"\n");
           restaurant.append("Day"+(j+1)+"\n");
           for(int a=0;a<out.getDayPlan().get(j).getVisitingPlpaces().size();a++)
           {
               String temp1=out.getDayPlan().get(j).getVisitingPlpaces().get(a).getCity();
               String temp2=out.getDayPlan().get(j).getVisitingPlpaces().get(a).getName();
               String temp3=Double.toString(roundTwoDecimals(out.getDayPlan().get(j).getVisitingPlpaces().get(a).getApproximateTime()));

               visitingPlaces.append("Around:"+temp3+" :"+temp2+"-"+temp1+"\n");
           }
           for(int a=0;a<out.getDayPlan().get(j).getMorningMeal().size();a++)
           {
               String temp1=out.getDayPlan().get(j).getMorningMeal().get(a).getCity();
               String temp2=out.getDayPlan().get(j).getMorningMeal().get(a).getName();
               String temp3=Double.toString(roundTwoDecimals(out.getDayPlan().get(j).getMorningMeal().get(a).getApproximateTime()));

               breakFirst.append("Around:"+temp3+" :"+temp2+"-"+temp1+"\n");
           }
           for(int a=0;a<out.getDayPlan().get(j).getLunch().size();a++)
           {
               String temp1=out.getDayPlan().get(j).getLunch().get(a).getCity();
               String temp2=out.getDayPlan().get(j).getLunch().get(a).getName();
               String temp3=Double.toString(roundTwoDecimals(out.getDayPlan().get(j).getLunch().get(a).getApproximateTime()));

               Lunch.append("Around:"+temp3+" :"+temp2+"-"+temp1+"\n");
           }
           for(int a=0;a<out.getDayPlan().get(j).getEvening().size();a++)
           {
               String temp1=out.getDayPlan().get(j).getEvening().get(a).getCity();
               String temp2=out.getDayPlan().get(j).getEvening().get(a).getName();
               String temp3=Double.toString(roundTwoDecimals(out.getDayPlan().get(j).getEvening().get(a).getApproximateTime()));

               evening.append("Around:"+temp3+" :"+temp2+"-"+temp1+"\n");
           }
           for(int a=0;a<out.getDayPlan().get(j).getDinner().size();a++)
           {
               String temp1=out.getDayPlan().get(j).getDinner().get(a).getCity();
               String temp2=out.getDayPlan().get(j).getDinner().get(a).getName();
               String temp3=Double.toString(roundTwoDecimals(out.getDayPlan().get(j).getDinner().get(a).getApproximateTime()));

               dinner.append(temp2+"-"+temp1+"\n");
           }
           for(int a=0;a<out.getDayPlan().get(j).getRestaurant().size();a++)
           {
               String temp1=out.getDayPlan().get(j).getRestaurant().get(a).getCity();
               String temp2=out.getDayPlan().get(j).getRestaurant().get(a).getName();
               String temp3=Double.toString(roundTwoDecimals(out.getDayPlan().get(j).getRestaurant().get(a).getApproximateTime()));

               restaurant.append(temp2+"-"+temp1+"\n");
           }
           for(int a=0;a<out.getDayPlan().get(j).getSuggestions().size();a++)
           {
               String temp1=out.getDayPlan().get(j).getSuggestions().get(a).getCity();
               String temp2=out.getDayPlan().get(j).getSuggestions().get(a).getName();
               String temp3=Double.toString(out.getDayPlan().get(j).getSuggestions().get(a).getApproximateTime());

               suggestions.append(temp2+"-"+temp1+"\n");
           }

        }
        
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel8 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        visitingPlaces = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        suggestions = new javax.swing.JTextArea();
        jScrollPane3 = new javax.swing.JScrollPane();
        breakFirst = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        Lunch = new javax.swing.JTextArea();
        jScrollPane5 = new javax.swing.JScrollPane();
        evening = new javax.swing.JTextArea();
        jScrollPane6 = new javax.swing.JScrollPane();
        dinner = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        restaurant = new javax.swing.JTextArea();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        route = new javax.swing.JLabel();

        jLabel8.setText("jLabel8");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        visitingPlaces.setColumns(20);
        visitingPlaces.setRows(5);
        jScrollPane1.setViewportView(visitingPlaces);

        suggestions.setColumns(20);
        suggestions.setRows(5);
        jScrollPane2.setViewportView(suggestions);

        breakFirst.setColumns(20);
        breakFirst.setRows(5);
        jScrollPane3.setViewportView(breakFirst);

        Lunch.setColumns(20);
        Lunch.setRows(5);
        jScrollPane4.setViewportView(Lunch);

        evening.setColumns(20);
        evening.setRows(5);
        jScrollPane5.setViewportView(evening);

        dinner.setColumns(20);
        dinner.setRows(5);
        jScrollPane6.setViewportView(dinner);

        jLabel1.setText("Visiting Places");

        jLabel2.setText("Suggestions");

        jLabel3.setText("Break First");

        jLabel4.setText("Lunch");

        jLabel5.setText("Evening");

        jLabel6.setText("Dinner");

        restaurant.setColumns(20);
        restaurant.setRows(5);
        jScrollPane7.setViewportView(restaurant);

        jLabel7.setText("Restaurant");

        jLabel9.setText("Route");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 616, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel1)
                                        .addGap(292, 292, 292))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addGap(307, 307, 307))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                                            .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE))
                                        .addGap(73, 73, 73)))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel6)
                                    .addComponent(jScrollPane2)
                                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)
                                    .addComponent(jScrollPane6))
                                .addGap(25, 25, 25))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(184, 184, 184)
                                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(route, javax.swing.GroupLayout.DEFAULT_SIZE, 632, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(316, 316, 316)
                        .addComponent(jLabel7)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(route, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(8, 8, 8)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PlanOut(null).setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea Lunch;
    private javax.swing.JTextArea breakFirst;
    private javax.swing.JTextArea dinner;
    private javax.swing.JTextArea evening;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTextArea restaurant;
    private javax.swing.JLabel route;
    private javax.swing.JTextArea suggestions;
    private javax.swing.JTextArea visitingPlaces;
    // End of variables declaration//GEN-END:variables

}
